<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/12/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/12/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/FPGA%E7%82%B9%E4%BA%AELED/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/FPGA%E7%82%B9%E4%BA%AELED/" class="post-title-link" itemprop="url">FPGA点亮LED</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 17:21:28" itemprop="dateCreated datePublished" datetime="2023-02-19T17:21:28+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FPGA/" itemprop="url" rel="index"><span itemprop="name">FPGA</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/FPGA%E7%82%B9%E4%BA%AELED/" class="post-meta-item leancloud_visitors" data-flag-title="FPGA点亮LED" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/FPGA%E7%82%B9%E4%BA%AELED/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/FPGA%E7%82%B9%E4%BA%AELED/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="1-画框图"><a href="#1-画框图" class="headerlink" title="1.画框图"></a>1.画框图</h3><p>​        先设计LED的框图，模块有两个信号，一个是输入信号，一个是输出信号。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191421776.png" style="zoom:50%;">

<h3 id="2-画波形图"><a href="#2-画波形图" class="headerlink" title="2.画波形图"></a>2.画波形图</h3><p>​        具体模块的功能使用波形图来实现：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191456794.bmp" style="zoom:87%;">

<p>输出波形和输入波形是一样的。</p>
<h3 id="3-代码编写"><a href="#3-代码编写" class="headerlink" title="3.代码编写"></a>3.代码编写</h3><p>​        按博文《Vivado新建ZYNQ工程》中建立好工程后，在工程管理栏点击 Add Sources 添加我们需要编写设计的led灯代码文件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191600255.png" style="zoom:67%;">

<p>​        弹出的界面勾选 Addorcreatedesignsources，表示添加或者新建一个设计文档，然后点击 next</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191602852.png" style="zoom:67%;">

<p>​        然后点击 Create File ,弹出的子对话框中，File Type 默认是 verilog，File Name 填入 verilog 文件名，我们这里填入的是 led。然后点击 OK</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191606344.png" style="zoom:67%;">

<p>​        点击 Finish 完成文档创建。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191611681.png" style="zoom:47%;">

<p>​        点击Finish 之后，弹出对应文档的模块名称。这里我们默认led，然后点击OK。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191614263.png" style="zoom:60%;">

<p>​        我们可以看到，led模块和文档已经在设计文件层次窗口中:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191615526.png" style="zoom:67%;">

<p>​        我们双击打开 led, 然后对其进行编辑，添加如下代码</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191627051.png" style="zoom:67%;">

<p><strong>语法补充：assign语句</strong></p>
<p>​        被assign语句赋值的信号通常我们要定义成wire类型。</p>
<h3 id="4-综合"><a href="#4-综合" class="headerlink" title="4.综合"></a>4.综合</h3><p>​        开始综合，点击工程管理栏的 Run Synthesis：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191633315.png" style="zoom:60%;">

<p>​        然后弹出的 Launch Runs 对话框根据电脑配置选择 Jobs 数量（代表综合消耗的进线程，VIVADO 目前已验证过支持 12 线程，  综合过程很耗 CPU性能，所以如果想要综合过程中流畅使用电脑，可以少选两个线程。选完线程数量，点击OK 进行综合。（综合过程很慢，请耐心等待）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191636607.png" style="zoom:67%;">

<p>​        综合状态可以在右上角看到已经开始运行。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191637365.png" style="zoom:67%;">

<p>​        完成综合后，<strong>弹出的综合完成对话框中我们点击 Cancel 取消。不要进行 Implementation</strong>。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191639006.png" style="zoom:50%;">

<h3 id="5-管脚绑定"><a href="#5-管脚绑定" class="headerlink" title="5.管脚绑定"></a>5.管脚绑定</h3><p>​        由于我们还没有进行管脚绑定，所以我们需要先绑定管脚再进行 Implementation 实现，最后<br>布局布线最后生成 BIT 文件。我们接下来进行绑定管脚。我们点击工程管理栏的 RTL ANALYSIS<br>下面的&gt;open Elaborated Design：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191642974.png" style="zoom:67%;">

<p>弹出的对话框我们选择 OK。</p>
<p>​        然后右上角，软件运行状态下面的视图选择。我们默认是 Default Layout，但是我们要进行IO 绑定，我们选择 I/O Planning。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191644557.png" style="zoom:67%;">

<p>选择 I/O Planning 之后出现如下视图，在下面窗口部分，I/O Ports 即可进行 IO 管脚绑定。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191649748.png" style="zoom:60%;">

<p>​        根据原理图绑定的管脚如下所示：（电平标准都选择 LVCMOS33）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191656397.png" style="zoom:80%;">

<p>​        按下 ctrl+s 保存，弹出的保存对话框，填入管脚约束文件名。我们这里取为 led</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191658163.png" style="zoom:67%;">

<h3 id="6-布局布线生成bit文件"><a href="#6-布局布线生成bit文件" class="headerlink" title="6.布局布线生成bit文件"></a>6.布局布线生成bit文件</h3><p>​        我们点击工程管理栏的 PROGRAM AND DEBUG 下面的 Generate Bitestream 生成 BIT文件。（也可以先点击 IMPLEMENTATION 下面的 Run implementation 先进行实现，实现包括布局布线，<strong>这里直接生成 bit 文件包含了实现操作</strong>）。弹出的对话框为综合信息过期。这里默认点击 OK（由于软件综合后才能有模块的顶层引脚信息，才能进行绑定管脚。我们绑定管脚之后，软件认为工程信息发生了变更所以需要再次综合）。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191703889.png" style="zoom:60%;">

<p>​        接着还会弹出综合线程数量对话框。我们也选择默认，然后点击OK。然后软件开始了生成比特流的一系列工作。流程是：综合-&gt;实现（布局布线）-&gt;生成bit 文件。我们等待软件运行这些操作结束，结束后弹出如下对话框，这里我们选择打开硬件管理器 Open Hardware Mnager:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191705970.png" style="zoom:67%;">

<h3 id="7-烧录bit文件"><a href="#7-烧录bit文件" class="headerlink" title="7.烧录bit文件"></a>7.烧录bit文件</h3><p>​        弹出的硬件管理界面，这个时候可以插上我们的ZYNQ开发板的下载器USB接口（TYPE-C的DEBUG口）进行调试。如果开发板黄色LED亮起，说明开发板已经上电，可以连接。点击上方的Open Target:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191707429.png" style="zoom:87%;">

<p>弹出的下拉界面选择点击 Auto target，自动连接目标开发板。点击之后待连接完成。</p>
<p>​        连接完成之后，可以看到 Hardware 窗口出现了两个设备，一个是arm的dap，一个是xc7z010 芯片。<strong>上方我们点击Program Device进行烧写配置</strong>（断电就丢失。需要下载到 FLASH的教程我们在后面介绍步骤）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191714058.png" style="zoom:67%;">

<p>弹出的烧写对话框，默认都不改动，其中Bitstream file表示选择的bit文件，也就是上面我们生成的bit文件。点击 program：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191715381.png" style="zoom:67%;">

<p>烧写完成，我们按下key2，led1灭；松开key2，led1亮。本节教程结束。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/timegen%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/timegen%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">timegen使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 14:52:21" itemprop="dateCreated datePublished" datetime="2023-02-19T14:52:21+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FPGA/" itemprop="url" rel="index"><span itemprop="name">FPGA</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/timegen%E4%BD%BF%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="timegen使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/timegen%E4%BD%BF%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/timegen%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        1.画时钟，你可以直接选择时钟图标，点击一下时钟就画出来了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191439983.png" style="zoom:67%;">

<p>​        2.单击“sig”，添加信号线；</p>
<p>​        单击“bus”，添加总线；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191441391.png" style="zoom:67%;">

<p>​        3.修改信号名称<br>​        加入的信号线与总线名称以默认方式显示，此时我们需要根据我们的需求对其名称进行修改；<br>​        该软件分“绘图模式”与“编辑模式” ，<br>​        (a)点击“Mode”，显示“draw”与“edit”，选择“edit”进入“编辑模式”；<br>​        (b)双击需要改名的信号线或总线，弹出如下图所示窗口，编辑名称进行保存；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191446223.png" style="zoom:67%;">

<p>​        4.绘制波形</p>
<p>​        图示3个小工具是该软件的主要绘制工具，其使用效果如图所示；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191449214.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/%E5%BF%AB%E9%80%9F%E7%90%86%E8%A7%A3FPGA%E8%AE%BE%E8%AE%A1%E6%B5%81%E7%A8%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/%E5%BF%AB%E9%80%9F%E7%90%86%E8%A7%A3FPGA%E8%AE%BE%E8%AE%A1%E6%B5%81%E7%A8%8B/" class="post-title-link" itemprop="url">快速理解FPGA设计流程</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 13:59:28" itemprop="dateCreated datePublished" datetime="2023-02-19T13:59:28+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FPGA/" itemprop="url" rel="index"><span itemprop="name">FPGA</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/%E5%BF%AB%E9%80%9F%E7%90%86%E8%A7%A3FPGA%E8%AE%BE%E8%AE%A1%E6%B5%81%E7%A8%8B/" class="post-meta-item leancloud_visitors" data-flag-title="快速理解FPGA设计流程" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/%E5%BF%AB%E9%80%9F%E7%90%86%E8%A7%A3FPGA%E8%AE%BE%E8%AE%A1%E6%B5%81%E7%A8%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/%E5%BF%AB%E9%80%9F%E7%90%86%E8%A7%A3FPGA%E8%AE%BE%E8%AE%A1%E6%B5%81%E7%A8%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/69415960">https://zhuanlan.zhihu.com/p/69415960</a></p>
<h3 id="一、FPGA设计流程"><a href="#一、FPGA设计流程" class="headerlink" title="一、FPGA设计流程"></a>一、FPGA设计流程</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191320866.png" style="zoom:80%;">

<h4 id="1-设计定义"><a href="#1-设计定义" class="headerlink" title="1.设计定义"></a>1.设计定义</h4><p>​        设计定义阶段主要进行方案验证、系统设计和FPGA芯片选型等准备工作。根据任务要求，评估系统的指标和复杂度，对工作速度和芯片本身的资源、成本等方面进行权衡，选择合理的设计方案和合适的器件类型。</p>
<p>​        这个阶段往往会花费大量的时间，这个阶段之后一般已经完成了系统建模，功能划分，模块划分以及设计文档的撰写等工作。</p>
<h4 id="2-代码实现"><a href="#2-代码实现" class="headerlink" title="2.代码实现"></a>2.代码实现</h4><p>​        代码实现阶段是将划分好的各功能模块用硬件描述语言表达出来，常用的硬件描述语言有Verilog HDL和VHDL。下面是一个四选一电路的代码实现过程：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191321058.png" style="zoom:47%;">

<h4 id="3-功能仿真"><a href="#3-功能仿真" class="headerlink" title="3.功能仿真"></a>3.功能仿真</h4><p>​        功能仿真是在编译之前对用户所设计的电路进行逻辑功能验证，<strong>此时的仿真没有延迟信息，仅对初步的功能进行检测</strong>。这里我们补充一个延迟类型的知识点：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191323798.webp" style="zoom:63%;">

<p>​        我们知道信号在电路中传输时会有两种延迟：器件延迟和路径延迟。</p>
<p>​        顾名思义，器件延迟是信号在经过器件传输时的延迟时间，器件延迟与器件本身特质相关；路径延迟是信号经过连接线时的延迟时间，与连线长度成正比。</p>
<p>​        上图中信号从a到b的延迟时间为T1+T2+T3+T4+T5，其中器件延迟是T1、T3、T5，路径延迟是T2、T4。在功能仿真中，这些延迟信息都为零。</p>
<h4 id="4-逻辑综合"><a href="#4-逻辑综合" class="headerlink" title="4.逻辑综合"></a>4.逻辑综合</h4><p>​        逻辑综合的概念是：将高级抽象层次的语言描述转化成较低层次的电路结构。</p>
<p>​        也就是说将硬件描述语言描述的电路逻辑转化成与门、或门、非门、触发器等基本逻辑单元的互连关系，也就是我们常说的门级网表。。</p>
<p>​        还是以四选一电路为例，综合过程将Verilog代码翻译成了门级互连网表。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191328086.png" style="zoom:67%;">

<p>​        综合的概念很重要，利用Verilog 做电路设计时我们总是强调可综合的概念，可综合就是我们的这段代码可以被翻译成门级电路，不可综合就是代码不能被翻译成与之对应的门级电路。</p>
<p>​        综合是创造性的转化过程，它不但能翻译我们的电路，还能够优化我们的电路，比如去除电路描述中冗余的电路结构，或者复用功能相同的电路结构。</p>
<p>​        Verilog中可综合的语法多用于电路设计，那么为什么还要有不可综合的语法呢？不可综合的语法用于仿真测试。</p>
<h4 id="5-前仿真"><a href="#5-前仿真" class="headerlink" title="5.前仿真"></a>5.前仿真</h4><p>​        前仿真也叫做综合后仿真，仿真时，把综合生成的标准延时文件反标注到综合仿真模型中去。</p>
<p>​        因为综合后只能体现基本的逻辑门之间的互连关系，<strong>并不是实物电路，没有连线长度信息，所以前仿真只能评估门延时带来的影响</strong>，不能估计路径延时，前仿真结果和布线后实际情况还有一定的差距，并不十分准确。</p>
<p>​        目前的综合工具较为成熟，一般的设计可以省略这一步。但如果布局布线后发现电路功能与设计意图不符，就需要回溯到前仿真来确定问题所在。</p>
<h4 id="6-布局布线"><a href="#6-布局布线" class="headerlink" title="6.布局布线"></a>6.布局布线</h4><p>​        综合后生成的门级网表只是表示了门与门之间虚拟的连接关系，并没有规定每个门的位置以及连线长度等。布局布线就是一个将门级网表中的门的位置以及连线信息确定下来的过程。</p>
<p>​        综合后生成的门级网表只是虚拟的连接关系，并没有反应到实物上去。布局布线有时也叫作实现与布局布线，布局布线将逻辑网表中的门级连接关系配置到FPGA芯片内部的固有硬件结构上。布局布线过程将每一个门实际配置到固定位置的可编程逻辑块（CLB）中，</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191338873.png" style="zoom:67%;">

<p>​        在解释布局布线之前，我们先回顾一下FPGA的结构，我们知道FPGA可重复编程的基础是拥有巨量的可配置逻辑块（CLB）、丰富的布线资源以及其他资源</p>
<p>​        ①布局</p>
<p>​        布局的过程就是将门级网表中的每一个门“安置”到CLB中的过程，这个过程是一个映射的过程。</p>
<p>​        ②布线</p>
<p>​        布线是利用FPGA中丰富的布线资源将CLB根据逻辑关系连接在一起的过程。</p>
<p>​        逻辑门的映射位置不是随意的，是FPGA设计软件经过算法计算后精心排列的一般的布局布线策略是占用最少的CLB并且连线尽量短，也就是面积和速度最优。</p>
<p>​        布局布线策略有两种：速度优先和面积优先，往往不能同时达到两者皆最优，所以布局布线时需要在速度最优和面积最优之间做出选择。</p>
<p>​        布局布线后就可以进行静态时序分析了，<strong>静态时序分析的方法是在布局布线后的实际电路中寻找寄存器和寄存器之间的最长路径延迟，通过最大延迟可以得出系统最大时钟速率</strong>。静态时序分析也是EDA工具自动完成，延迟路径信息可以在生成的时序报告中分析。</p>
<h4 id="7-后仿真"><a href="#7-后仿真" class="headerlink" title="7.后仿真"></a>7.后仿真</h4><p>​        后仿真也称为时序仿真，是将布局布线的延时信息反标注到设计网表中来检测有无时序违规。</p>
<p>​        经过布局布线后，门与门之间的连线长度也确定了，所以后仿真包含的延迟信息最全，也最精确，能更好的反映芯片的额实际工作情况。</p>
<p>​        现在我们可以总结一下功能仿真、前仿真和后仿真的区别了：</p>
<p>​        <strong>功能仿真</strong>：无延迟信息；</p>
<p>​        <strong>前仿真</strong>：只有门级的延迟；</p>
<p>​        <strong>后仿真</strong>：门级延迟和连线延迟</p>
<h4 id="8-板级调试"><a href="#8-板级调试" class="headerlink" title="8.板级调试"></a>8.板级调试</h4><p>​        我们的FPGA设计不能只在电脑上跑仿真，最终还是要在电路板上应用起来的，设计的最后一步就是板级测试了，将EDA软件产生的数据文件（位数据流文件）下载到FPGA芯片中，进行实际的测试。</p>
<h3 id="二、FPGA设计流程直观对比"><a href="#二、FPGA设计流程直观对比" class="headerlink" title="二、FPGA设计流程直观对比"></a>二、FPGA设计流程直观对比</h3><p>​        为了方便初学者门能更快的了解FPGA的设计流程，看下面这个例子：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191354629.png" style="zoom:60%;">

<p>​        代码实现，综合和布局布线时FPGA设计流程中的几个关键步骤，下面我们打个比方加深理解一下这几个步骤是干什么的：</p>
<p>​        <strong>代码实现</strong>：比如我要盖一座房子，我把房子的特点描述出来：比如面积100平米、带阳台、欧式装修风格、挑高3米、一室两厅一厨一卫、卧室木地板客厅瓷砖。。。等等要求，这个描述房屋特点的过程就好比我们用Verilog描述电路功能的过程。</p>
<p>​        <strong>逻辑综合</strong>：建筑师根据我们的要求画出施工图纸，施工图纸将我的需求数字化、具体化，比如这个墙有多高，门有多宽，窗户面积等等，这个过程就好比综合的过程，将房屋需求翻译成具体的数字化图纸，只不过综合是将电路功能翻译成门级网表，建筑师干的活就是综合工具软件干的活。</p>
<p>​        <strong>布局布线</strong>：工人拿会根据图纸（综合后网表），用砖、水泥、钢筋、木材等材料建造施工的过程就好比布局布线的过程。图纸规定了一面墙，但是没有规定具体用哪一块砖来砌墙，工人可以自主决定用哪些砖。布局布线是根据综合后的网表（施工图纸），利用FPGA芯片内部的可编程逻辑块（CLB），布线资源，时钟资源，存储资源等搭建电路的过程。</p>
<p>​        综合和布局布线的过程中会涉及到约束策略的问题，比如管脚约束、时钟约束、面积和速度优先级等。这些概念在盖房子的过程中也有对应，比如你可以跟建筑师要求阳台大小、卧室朝向、门窗高度等，采购建筑材料时，你也会控制成本和质量之间的平衡。这些都类似于综合和布局布线过程中的约束条件。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-UUID/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-UUID/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-UUID</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 11:20:17" itemprop="dateCreated datePublished" datetime="2023-02-19T11:20:17+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-UUID/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-UUID" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-UUID/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-UUID/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=6&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=6&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        上一节中我们通过代码定义的服务和特性名字都是Unknown，这时怎么回事呢？其实，蓝牙组织联盟已经定义好了一些常用的UUID，我们在开发产品的时候直接使用即可。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191110565.png" style="zoom:67%;">

<h3 id="实战"><a href="#实战" class="headerlink" title="实战"></a>实战</h3><p>​        我们用定义好的UUID来实现一些服务和特性，看是否可以在手机上显示出对应的名称。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191114331.png" style="zoom:67%;">

<p>​        然后想知道那几个特性的值怎么设定，可以在下面这个文档里找到：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191117005.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191118121.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%95%B0%E6%8D%AE%E6%94%B6%E5%8F%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%95%B0%E6%8D%AE%E6%94%B6%E5%8F%91/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-数据收发</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 11:00:12" itemprop="dateCreated datePublished" datetime="2023-02-19T11:00:12+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%95%B0%E6%8D%AE%E6%94%B6%E5%8F%91/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-数据收发" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%95%B0%E6%8D%AE%E6%94%B6%E5%8F%91/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%95%B0%E6%8D%AE%E6%94%B6%E5%8F%91/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=6&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=6&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<h3 id="特性是数据点"><a href="#特性是数据点" class="headerlink" title="特性是数据点"></a>特性是数据点</h3><p>​        低功耗蓝牙通信是基于一个个特性实现的，<strong>每一个特性可以被看作一个数据点</strong>，数据的收发都要依托于这些数据点。对于数据点的操作方法，有常用的5种类型，我们在创建特性的时候，可以给特性赋予其中的一种或者几种权限。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191011359.png" style="zoom:67%;">

<h3 id="通信方式区别"><a href="#通信方式区别" class="headerlink" title="通信方式区别"></a>通信方式区别</h3><p>​        以手机连接蓝牙设备为例，介绍一下这几种通信方式的区别。</p>
<p>​        1.读操作就是手机读取设备中某个特性的值。</p>
<p>​        2.写操作就是手机修改设备中某个特性的值，写完后需要设备回应。</p>
<p>​        3.wreite with no response与write操作类似，只不过写完之后不需要设备回应。</p>
<p>​        4.notify操作是设备里面的数据发生变化后，通知手机来取数据，<strong>需要在手机端订阅相应的通知才有效</strong>。</p>
<p>​        5.indicate与notify操作类似，不同处在于indicate需要手机回应，notify则不需要。</p>
<h3 id="实战"><a href="#实战" class="headerlink" title="实战"></a><strong>实战</strong></h3><p>​        <strong>（1）</strong></p>
<p>​        当收到write请求时，我们将收到的数据读取出来，通过print打印。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191027476.png" style="zoom:67%;">

<p>​        在手机软件上写入一些数据：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191029376.jpg" style="zoom:15%;">

<p>​        这个时候设备就收到了这个数据并打印了出来：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191030650.png" style="zoom:67%;">

<p>​        <strong>（2）</strong></p>
<p>​        接下来再实验notify的操作：如果设备收到手机write的内容是A的话，就给手机notify一个字母B。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191036043.png" style="zoom:67%;">

<p>这里再补充一点，设备本身对所有的特性都有完全的读写权限，上面代码中就是通过read读取了手机write过来的数据。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%9C%8D%E5%8A%A1%E4%B8%8E%E7%89%B9%E6%80%A7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%9C%8D%E5%8A%A1%E4%B8%8E%E7%89%B9%E6%80%A7/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-服务与特性</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 10:06:45" itemprop="dateCreated datePublished" datetime="2023-02-19T10:06:45+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%9C%8D%E5%8A%A1%E4%B8%8E%E7%89%B9%E6%80%A7/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-服务与特性" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%9C%8D%E5%8A%A1%E4%B8%8E%E7%89%B9%E6%80%A7/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%9C%8D%E5%8A%A1%E4%B8%8E%E7%89%B9%E6%80%A7/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=5&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=5&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        这一讲是蓝牙中最重要的概念。</p>
<h3 id="蓝牙协议整体架构"><a href="#蓝牙协议整体架构" class="headerlink" title="蓝牙协议整体架构"></a>蓝牙协议整体架构</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190933082.png" style="zoom:80%;">

<p>​        最下面的是物理层，负责无线电波的收发以及信号链路的管理；中间部分是协议层，主要实现蓝牙协议栈；最上面的是应用层，根据业务需求来实现不同的应用程序。作为应用开发者只需要关注应用层就可以了，物理层和协议栈一般都是由芯片原厂来实现。协议栈里面主机与控制器之间的通信接口称为主机控制接口。</p>
<h3 id="一个蓝牙设备例子"><a href="#一个蓝牙设备例子" class="headerlink" title="一个蓝牙设备例子"></a>一个蓝牙设备例子</h3><p>​        蓝牙设备在应用层是通过服务和特性来实现的，一个蓝牙设备里面可以包含若干个服务，一个服务里面包含若干个特性，每个特性里面又可以有读写通知等权限，每个服务和特性都要有一个UUID。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190942491.png" style="zoom:75%;">

<p>​        UUID是蓝牙组织定义的，用于区分各个服务和特性的标识符。总长度128bit，比如下面就是两个标准的UUID。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190945535.png" style="zoom:67%;">

<p>​        考虑到128bit的UUID太长，使用起来不方便，蓝牙组织联盟定义了一个UUID的基地址，允许用户使用16bit的UUID，与该基地址拼接形成128bit的UUID。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190947115.png" style="zoom:67%;">

<h3 id="实战"><a href="#实战" class="headerlink" title="实战"></a>实战</h3><p>​        假如要构建下面这样一个应用程序：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190948650.png" style="zoom:67%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191005019.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302191005816.jpg" style="zoom:25%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-蓝牙状态切换</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 09:25:21" itemprop="dateCreated datePublished" datetime="2023-02-19T09:25:21+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-蓝牙状态切换" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=4&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=4&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<h3 id="蓝牙状态切换"><a href="#蓝牙状态切换" class="headerlink" title="蓝牙状态切换"></a>蓝牙状态切换</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190905322.png" style="zoom:67%;">

<p>​        设备上电后，就会进入就绪态。</p>
<p>​        发起广播就会进入广播态。</p>
<p>​        如果被别的设备连接就会进入连接态，断开连接就会再次回到就绪态。</p>
<p>​        蓝牙主机可以在就绪态发起扫描，进入扫描态；如果发现了想要连接的设备，可以发起连接，此时将进入发起连接态。如果对方接受了连接，则双方都会进入连接态。</p>
<p>​        我们在编程的时候，需要控制蓝牙的状态；或者根据状态的改变来做出一些动作。</p>
<h3 id="实战"><a href="#实战" class="headerlink" title="实战"></a>实战</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190912584.png" style="zoom:80%;">

<p>​        但是在实际应用中，我们希望蓝牙设备断开连接后，可以再次被搜索并且连接，需要对程序做一些修改。当设备从连接态进入就绪态后，我们使其再次进入广播态。这里我们在中断函数中来处理蓝牙状态的变化。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190925909.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%89%AB%E6%8F%8F%E5%93%8D%E5%BA%94/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%89%AB%E6%8F%8F%E5%93%8D%E5%BA%94/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-扫描响应</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 08:57:21" itemprop="dateCreated datePublished" datetime="2023-02-19T08:57:21+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%89%AB%E6%8F%8F%E5%93%8D%E5%BA%94/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-扫描响应" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%89%AB%E6%8F%8F%E5%93%8D%E5%BA%94/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E6%89%AB%E6%8F%8F%E5%93%8D%E5%BA%94/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=3&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=3&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<h3 id="蓝牙广播分类"><a href="#蓝牙广播分类" class="headerlink" title="蓝牙广播分类"></a>蓝牙广播分类</h3><p>​        大致可以分为以下四类：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190841583.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190842702.png" style="zoom:60%;">

<h3 id="扫描响应"><a href="#扫描响应" class="headerlink" title="扫描响应"></a>扫描响应</h3><p>​        蓝牙广播是蓝牙设备主动发射的一些数据，<strong>而扫描响应呢，是蓝牙从机收到蓝牙主机的扫描请求之后，回复给蓝牙主机的数据</strong>。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190848119.png" style="zoom:67%;">

<p>​        扫描响应的数据格式和蓝牙广播的数据格式是完全一样的，不同的是广播数据是主动发射的，而扫描响应的数据是在收到其他设备的扫描请求之后，才会触发的。之前我们说蓝牙广播只能广播31个字节的数据，如果我们要广播的数据超过了31个字节，我们可以把一部分的数据放到扫描响应里面。</p>
<h3 id="实战："><a href="#实战：" class="headerlink" title="实战："></a>实战：</h3><p>​        在上一节的基础上，我们增加一个扫描响应的数据，数据内容我们把它设定为厂商自定义数据，然后通过手机来验证。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190854033.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190855111.jpg" style="zoom:25%;">

<p>可以看到不仅收到了广播数据还收到了扫描响应数据，扫描响应数据是非必须的，可以作为广播数据的补充，扫描响应需要有一定的触发条件(收到扫描请求)。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E5%B9%BF%E6%92%AD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E5%B9%BF%E6%92%AD/" class="post-title-link" itemprop="url">esp32低功耗蓝牙-蓝牙广播</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 08:37:23" itemprop="dateCreated datePublished" datetime="2023-02-19T08:37:23+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%93%9D%E7%89%99/" itemprop="url" rel="index"><span itemprop="name">蓝牙</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E5%B9%BF%E6%92%AD/" class="post-meta-item leancloud_visitors" data-flag-title="esp32低功耗蓝牙-蓝牙广播" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E5%B9%BF%E6%92%AD/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%E4%BD%8E%E5%8A%9F%E8%80%97%E8%93%9D%E7%89%99-%E8%93%9D%E7%89%99%E5%B9%BF%E6%92%AD/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考来源：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1ad4y1d7AM/?p=2&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1ad4y1d7AM/?p=2&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        低功耗蓝牙一共有40个信道，频段范围从2402MHz到2480MHz，每2MHz一个信道。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182045103.png" style="zoom:47%;">

<p>其中37，38，39是广播信道，剩余的是数据信道，可以发现这3个信道是分布在不同的位置。蓝牙广播就是在这三个信道上广播数据。</p>
<h3 id="蓝牙广播数据帧格式"><a href="#蓝牙广播数据帧格式" class="headerlink" title="蓝牙广播数据帧格式"></a>蓝牙广播数据帧格式</h3><p>​        一个广播数据包最多37个字节，其中有6个字节用作蓝牙设备的MAC地址，我们只需要关注剩余的31个字节就可以了。这31个字节又被分为若干个广播数据结构体，蓝牙规范里面称为AD Structure。每一个结构体都有三部分组成，分别是结构体长度，类型和内容。其中长度占用一个字节，类型占用一个字节，内容若干个字节。长度等于类型占据的字节数加内容占据的字节数，可以简单理解为长度= 1+n。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182100236.png" style="zoom:87%;">

<p>​        看下面一个例子：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182101358.png"></p>
<p>​        一共有两个广播数据结构体，第一个广播数据结构体的长度为0x04，表示后面有四个字节属于这个结构体。一个广播数据包有31个字节，而上面数据中一共才9个字节，不满的会在后面自动补零。</p>
<h3 id="AD-Structure-类型"><a href="#AD-Structure-类型" class="headerlink" title="AD Structure 类型"></a>AD Structure 类型</h3><p>​        常见的广播类型可以参考下面这个表格：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182111143.png"></p>
<p>比如0x09表示蓝牙设备的名称，0x0A表示蓝牙设备的发射功率，0xFF表示的是厂商自定义数据。蓝牙设备名称采用的是UTF-8编码，0x31 32 33 34所表示的字符串是1234，所以第一个结构体就是指定了蓝牙设备名称为1234。第二个结构体指定发射功率为8dbm。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182116022.png"></p>
<h3 id="实战"><a href="#实战" class="headerlink" title="实战"></a>实战</h3><p>​        我们在设备上真实广播一下数据：0x02 0x01 0x05 0x05 0x09 0x42 0x69 0x62 0x69 0x02 0x0A 0x02</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302182128117.png" style="zoom:80%;">

<p>代码编写好之后，点击编译器右边的DownloadAndRun。在手机上安装BLE调试助手，并赋予其蓝牙和定位的权限。可以看到：搜索到一个名为Bibi的蓝牙设备。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190826069.jpg" style="zoom:27%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190829662.jpg" style="zoom:23%;">

<p><strong>蓝牙名称设置成中文：</strong></p>
<p>​        前面说了蓝牙名称使用的是UTF-8编码，理论上可以使用任何国家的语言。需要注意的是一个汉字UTF-8编码占用3个字节。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190835674.png" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190835321.jpg" style="zoom:33%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/02/19/esp32%20MicroPython%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/02/19/esp32%20MicroPython%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" class="post-title-link" itemprop="url">esp32 MicroPython开发环境搭建</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-02-19 08:22:43" itemprop="dateCreated datePublished" datetime="2023-02-19T08:22:43+08:00">2023-02-19</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/02/19/esp32%20MicroPython%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" class="post-meta-item leancloud_visitors" data-flag-title="esp32 MicroPython开发环境搭建" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/02/19/esp32%20MicroPython%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/02/19/esp32%20MicroPython%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="MicroPython固件烧录"><a href="#MicroPython固件烧录" class="headerlink" title="MicroPython固件烧录"></a>MicroPython固件烧录</h3><p>1.乐鑫固件烧录工具</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121544697.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121545830.png" style="zoom:67%;">

<p>2.MicroPython固件</p>
<p>​        一开始我没选对固件版本，后来使用的时候报下面这个错误：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190737542.png" style="zoom:80%;">

<p>那是因为：SPIRAM是一种通过SPI接口连接的外部存储，只有型号为ESP32-WROVER才带有SPIRAM。ESP32-WROOM不带SPIRAM。我的板子正好是：ESP32-WROOM_32E。</p>
<p>​        版本选择如下这个：<a target="_blank" rel="noopener" href="https://micropython.org/download/esp32/">https://micropython.org/download/esp32/</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302190821605.png" style="zoom:67%;">

<p>3.烧录</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121609085.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121618775.png" style="zoom:67%;">

<p>​        点击“ERASE”后，显示“等待上电同步”，这时按开发板上的“BOOT”按钮1秒左右即可；ERASE完成后，点击“START”，再次出现“等待上电同步”，同样按开发板上的“BOOT”按钮1秒左右即可；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121621870.png" style="zoom:67%;">

<h3 id="MicroPython-IDE选择"><a href="#MicroPython-IDE选择" class="headerlink" title="MicroPython IDE选择"></a>MicroPython IDE选择</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121654172.png" style="zoom:67%;">

<p>​        使用uPyCraft，操作起来比较简单。V1.1版本uPyCraft下载地址：<a target="_blank" rel="noopener" href="https://shyboy.oss-cn-shenzhen.aliyuncs.com/readonly/uPyCraft_V1.1.exe">https://shyboy.oss-cn-shenzhen.aliyuncs.com/readonly/uPyCraft_V1.1.exe</a> </p>
<p>​        下载后无需安装，双击即可运行（首次运行将提示安装字体，点击OK即可），打开后依次点击Tools&gt;&gt; Serial &gt;&gt; COM* 连接设备，出现右下图所示的 &gt;&gt;&gt; 说明连接设备成功。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202302121934437.png" style="zoom:67%;">

<p>​        依次点击 File &gt;&gt; Examples &gt;&gt; Basic &gt;&gt; Blink.py ，打开示例代码，点击后侧的三角形运行代码。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/11/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/11/">11</a><span class="page-number current">12</span><a class="page-number" href="/page/13/">13</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/13/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
